/* pts01Login.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pts01Login.h>
#include <wrapper/JavaStreamWrapper.h>

pts01Login::pts01Login()
    : McPacketToServer(0x01), version(0), username("")
{
}

pts01Login::pts01Login(int32_t version, std::string username)
    : McPacketToServer(0x01), version(version), username(username)
{
}

unsigned int pts01Login::length()
{
    return 1 + 4 + 2 + 8 + 2 + 4 + 1 + 1 + 1 + 1 + username.length();
}

void pts01Login::forge(std::ostream& out)
{
    JavaStreamWrapper jsw(out);

    jsw.writeByte(getPacketId());
    jsw.writeInt(version);
    jsw.writeUTF(username);
    jsw.writeLong(0);
    jsw.writeShort(0);
    jsw.writeInt(0);
    jsw.writeByte(0);
    jsw.writeByte(0);
    jsw.writeByte(0);
    jsw.writeByte(0);

}

int32_t pts01Login::getVersion()
{
    return version;
}

std::string pts01Login::getUsername()
{
    return username;
}


void pts01Login::setVersion(int32_t version)
{
    this->version = version;
}

void pts01Login::setUsername(std::string username)
{
    this->username = username;
}


